package com.talkyun.openx.server.core;

import com.talkyun.openx.server.impl.FastJsonInvoker;
import com.talkyun.openx.server.impl.SimpleServiceFactory;
import junit.framework.TestCase;
import org.junit.Test;

public class JsonInvokerTestCase extends TestCase {

    public static class User {
        private String userName;
        private String passWord;

        public String getUserName() {
            return userName;
        }

        public void setUserName(String userName) {
            this.userName = userName;
        }

        public String getPassWord() {
            return passWord;
        }

        public void setPassWord(String passWord) {
            this.passWord = passWord;
        }
    }

    public static class UserService {

        public User echo(User user) {
            user.setUserName("EC:" + user.getUserName());
            return user;
        }

        public long calc(int arg2, long arg3) {
            return arg3 + arg2;
        }

        public boolean login(String userName, String password) {
            return true;
        }
    }

    @Test
    public void testInvoke() {
        FastJsonInvoker invoker = new FastJsonInvoker(SimpleServiceFactory.getInstance());

        ServiceRequest sr = new ServiceRequest("123");
        sr.setMapping("game/user");
        sr.setMethod("echo");
        // sr.setArgs("[{}]");
        // invoker.invoke(null, sr);
    }
}